//
//  MessageCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/23.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#define O_WIDTH [UIScreen mainScreen].bounds.size.width


#import "MessageCell.h"

@implementation MessageCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
    
        NSInteger a = 70;
        NSInteger b = (O_WIDTH-15*2-a*4)/3;
        _timeLab = [[UILabel alloc] init];
        _timeLab.textColor = [UIColor blackColor];
        _timeLab.textAlignment = NSTextAlignmentCenter;
        _timeLab.font = [UIFont systemFontOfSize:12];
        _timeLab.text= @"2016-12-30";
        [self addSubview:_timeLab];
        [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(a, 20));
            make.left.equalTo(self.mas_left).offset(15);
            make.top.equalTo(self.mas_top).offset(8);
            
        }];
        
        _tongLab = [[UILabel alloc] init];
        _tongLab.textColor = [UIColor blackColor];
        _tongLab.font = [UIFont systemFontOfSize:12];
        _tongLab.text= @"涨价通知";
        _tongLab.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_tongLab];
        [_tongLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(a, 20));
            make.left.equalTo(_timeLab.mas_right).offset(b);
            make.top.equalTo(self.mas_top).offset(8);
            
        }];
        

        _nameLab = [[UILabel alloc] init];
        _nameLab.textColor = [UIColor blackColor];
        _nameLab.font = [UIFont systemFontOfSize:12];
        _nameLab.textAlignment = NSTextAlignmentCenter;
        _nameLab.text= @"admin";
        [self addSubview:_nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(a, 20));
            make.left.equalTo(_tongLab.mas_right).offset(b);
            make.top.equalTo(self.mas_top).offset(8);
            
        }];

        _xLab = [[UILabel alloc] init];
        _xLab.textColor = [UIColor orangeColor];
        _xLab.font = [UIFont systemFontOfSize:12];
        _xLab.textAlignment = NSTextAlignmentCenter;
        _xLab.text= @"查看详情";
        [self addSubview:_xLab];
        [_xLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(a, 20));
            make.right.equalTo(self.mas_right).offset(-15);
            make.top.equalTo(self.mas_top).offset(8);
            
        }];

        
        
    }
    return self;
}

-(void)setUpMessageCellWithTime:(NSString *)_time withZhuTi:(NSString *)_zhu withPeople:(NSString *)_people withXiang:(NSString *)_xing
{
    _timeLab.text = _time;
    _tongLab.text = _zhu;
    _nameLab.text = _people;
    _xLab.text = _xing;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
